import GChild from "../../Core/GView/GChild";
import ShaderUtil from "../../Shaders/Manager/ShaderUtil";
import { VIEW_ID } from "../Common/UI";
import { Res } from "../Common/UIResources";
import GameMgr from "../Logic/GameMgr";

const { ccclass, property, menu, executeInEditMode } = cc._decorator;
@ccclass @menu('View/Home/RankItem')

export default class RankItem extends GChild {
    @property(cc.Sprite) icon: cc.Sprite = null;

    @property({type: cc.Node, tooltip: "排名模块"})  rankNode: cc.Node = null;


    private _data: SSkillDataRaw = null;
    public setView(rank:number) {
         for (let index = 0; index < this.rankNode.children.length; index++) {
            const element = this.rankNode.children[index];
            element.active = (index+1) == rank;
            if (rank > 3 && index == 3){
                element.active = true;
                element.getComponent(cc.Label).string = rank + "";
            }
         }
    }

    // public setView(data: SSkillDataRaw, bool: boolean) {
    //     this._data = data;
    //     if (!bool) {
    //         ShaderUtil.gray(this.icon.node);

    //     } else {

    //     }
    //     this.assetImpl.spriteAtlasFrame(this.icon, Res.texture.views.skillIcon, data.icon.toString());
    // }

    /**点击技能详情 */
    public skillClick() {
        if (this.node.getComponent(cc.Button).interactable) {
            GameMgr.jumpToMgr.jumpGoTo(VIEW_ID.skillPage, this._data)
        }
    }
}